using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class GuarContractClassMap : EntityTypeConfiguration<GuarContractClass>
    {
        public GuarContractClassMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            // Table & Column Mappings
            this.ToTable("GuarContractClass");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.ClassId).HasColumnName("ClassId");
            this.Property(t => t.PlistId).HasColumnName("PlistId");
            this.Property(t => t.CovPlanId).HasColumnName("CovPlanId");
            this.Property(t => t.VisitCeiling).HasColumnName("VisitCeiling");
            this.Property(t => t.ContractId).HasColumnName("ContractId");
            this.Property(t => t.Itemceiling).HasColumnName("Itemceiling");
            this.Property(t => t.DaysCeiling).HasColumnName("DaysCeiling");
            this.Property(t => t.Copayment_Start_Value).HasColumnName("Copayment_Start_Value");
            this.Property(t => t.Deductible).HasColumnName("Deductible");
            this.Property(t => t.Copayment_End_Value).HasColumnName("Copayment_End_Value");
            this.Property(t => t.GCC_DailyCeiling).HasColumnName("GCC_DailyCeiling");

            // Relationships
            this.HasRequired(t => t.CoverageClass)
                .WithMany(t => t.GuarContractClasses)
                .HasForeignKey(d => d.ClassId);
            this.HasRequired(t => t.CoveragePlan)
                .WithMany(t => t.GuarContractClasses)
                .HasForeignKey(d => d.CovPlanId);
            this.HasRequired(t => t.GuarantorContract)
                .WithMany(t => t.GuarContractClasses)
                .HasForeignKey(d => d.ContractId);
            this.HasRequired(t => t.PriceLst)
                .WithMany(t => t.GuarContractClasses)
                .HasForeignKey(d => d.PlistId);

        }
    }
}
